home *** CD-ROM | disk | FTP | other *** search
- /*
- title mode operation
- 1993.6.27 v1.0
- copyright Y.Ouchi
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include "egb.h"
- #include "mos.h"
- #include "bb.h"
-
- /* 関数プロトタイプ宣言 */
- extern char egbwork[];
- extern char moswork[];
- extern void linedsp(int, int, char *);
- extern void linedspv(int, int, char *, int, unsigned int, unsigned int);
- extern void box(int, int, int, int, int, int);
- extern int panelread(int, struct panel *, int);
- void lineset(char *, struct logcontent *, short *, int, char *);
-
- extern int max_text;
- extern int dispmode;
-
- int titlemod ( char *log, int leng, char **title,
- struct logcontent *intext, short *disptext, int *textno)
- {
- int i,k,flag,n;
- char logtitle[TITLE_LINE_NO][90];
- char logkind[TITLE_LINE_NO];
- int tcol;
- int pos=0;
- int result,action;
- int logindex;
- char *change_page={"▲ page up/down ▼ ( use mouse bottan or pad trigger )"};
- struct panel n_menu[1];
-
-
- /* page move char display */
- EGB_writePage(egbwork,1);
- linedsp( 6,52,change_page );
- EGB_writePage(egbwork,0);
-
- /* title display select */
- MOS_horizon( 0,639 );
- MOS_vertical( 35,448 );
- MOS_setpos( 120, 60 );
- MOS_disp( 1 );
-
- flag=1;
- while ( flag ){
-
- /* title dsiplay arrary make */
- for (i=0;i<TITLE_LINE_NO;i++){
- if ( *textno+i < max_text ){
- logindex=disptext[*textno+i];
- if (intext->text[logindex].text.id!=TITLE_ID){
- if (intext->text[logindex].text.leng>0){
- lineset(log,intext,disptext,*textno+i,logtitle[i]);
- logkind[i]=0;
- }
- else{
- logtitle[i][0]=0x00;
- }
- }
- else{
- strcpy(logtitle[i],
- title[intext->text[logindex].title.index]);
- logkind[i]=1;
- }
- }
- else{
- logtitle[i][0]=0x00;
- }
- }
-
- for (k=0;k<TITLE_LINE_NO;k++){
- if (logkind[k]==0) tcol=TEXT_COL;
- else tcol=NAME_COL;
- linedspv ( 2, k*18+69, logtitle[k],0,tcol,BACK_COL);
- }
-
- n_menu[0].xpos=0;
- n_menu[0].ypos=35;
- n_menu[0].xsize=640;
- n_menu[0].ysize=414;
- n_menu[0].xbtnsize=640;
- n_menu[0].ybtnsize=18;
- n_menu[0].ful=0;
- n_menu[0].disp=0;
- n_menu[0].ini_digit=0;
- while ( (result = panelread (1, n_menu, 1)) >= 2000 );
- if ( result<0 ) action=0;
- else{
- if ( result < 1000 ){
- action=1;
- pos=result;
- }
- else{
- action=2;
- pos=result-1000;
- }
- }
-
- switch ( action ){
- case 0 :
- flag=0;
- MOS_disp( 0 );
- EGB_writePage(egbwork,1);
- box( 0,35,639,459,0,1 );
- EGB_writePage(egbwork,0);
- break;
- case 1 :
- if ( pos==0 ){
- if (*textno+TITLE_LINE_NO < max_text)
- *textno=*textno+TITLE_LINE_NO;
- }
- else{
- *textno=*textno+pos-1;
- if ( *textno>max_text-1 ) *textno=max_text-1;
- if (intext->text[disptext[*textno]].title.id==TITLE_ID){
- for ( n=*textno;n<max_text-1;n++ ){
- if (intext->text[disptext[n]].text.id
- != TITLE_ID ) break;
- }
- *textno=n;
- }
- flag=0;
- MOS_disp( 0 );
- EGB_writePage(egbwork,1);
- box( 0,35,639,459,0,1 );
- EGB_writePage(egbwork,0);
- }
- break;
- case 2 :
- if ( pos==0 ){
- *textno=*textno-TITLE_LINE_NO;
- if (*textno<0) *textno=0;
- }
- else{
- flag=0;
- MOS_disp( 0 );
- EGB_writePage(egbwork,1);
- box( 0,35,639,459,0,1 );
- EGB_writePage(egbwork,0);
- break;
- }
- break;
- }
- EGB_color(egbwork, 0, TEXT_COL);
- EGB_clearScreen(egbwork);
- }
- MOS_disp( 0 );
- EGB_color(egbwork, 0, TEXT_COL);
- EGB_color(egbwork, 1, BACK_COL);
-
- return(0);
-
- }
-
- /*
- display charactor set with comment level mark
- */
- void lineset(char *log,struct logcontent *logc,
- short *dsp,int txtp,char *dest)
- {
- int i,j;
- int com;
- char *src;
-
- if (dispmode==NORMAL_MODE) com=0;
- else com=logc->text[dsp[txtp]].text.com_lvl;
- src=&(log[logc->text[dsp[txtp]].text.pos]);
-
- switch (abs(com)){
- case 0 :
- break;
- case 1 :
- dest[0]=0x84;
- if (com>0) dest[1]=0xaf;
- else dest[1]=0xb0;
- break;
- default :
- for (i=0;i<(abs(com)-1)*2;i=i+2){
-
- dest[i]=0x20;
- dest[i+1]=0x20;
- for (j=txtp-1;j>=0;j--){
- if (logc->text[dsp[j]].text.com_lvl==0){
- break;
- }
- if (abs(logc->text[dsp[j]].text.com_lvl)==(i+2)/2){
- if (logc->text[dsp[j]].text.com_lvl < 0){
- dest[i]=0x84;
- dest[i+1]=0xab;
- }
- else break;
- }
- }
- }
- dest[(abs(com)-1)*2]=0x84;
- if (com>0) dest[(abs(com)-1)*2+1]=0xaf;
- else dest[(abs(com)-1)*2+1]=0xb0;
- break;
- }
-
- if(com==0){
- for (i=0;i<80;i++){
- if (src[i]==0x0d && src[i+1]==0x0a){
- dest[i]=0x00;
- break;
- }
- else{
- dest[i]=src[i];
- }
- }
- }
- else{
- for (i=0;i<80-abs(com)*2;i++){
- if (src[i]==0x0d && src[i+1]==0x0a){
- dest[i+abs(com)*2]=0x00;
- break;
- }
- else{
- dest[i+abs(com)*2]=src[i];
- }
- }
- }
- dest[81]=0x00;
- return;
- }
-
-
- int ttitlemod ( char *log, int leng, char **title,
- struct logcontent *intext, short *disptext, int *textno)
- {
- int i,k,flag,n;
- char logtitle[TITLE_LINE_NO][90];
- char logkind[TITLE_LINE_NO];
- short logno[TITLE_LINE_NO];
- int tcol;
- int workid;
- int pos=0;
- int result,action;
- int logindex;
- char *change_page={"▲ page up/down ▼ ( use mouse bottan or pad trigger )"};
- struct panel n_menu[1];
-
-
- /* page move char display */
- EGB_writePage(egbwork,1);
- linedsp( 6,52,change_page );
- EGB_writePage(egbwork,0);
-
- /* title display select */
- MOS_horizon( 0,639 );
- MOS_vertical( 35,448 );
- MOS_setpos( 120, 60 );
- MOS_disp( 1 );
-
- for (i=*textno;i>0;i--){
- if (intext->text[disptext[i]].text.id==TITLE_ID ||
- intext->text[disptext[i]].text.id==NOTITLE_TEXT_ID) break;
- }
- *textno=i;
-
- flag=1;
- while ( flag ){
-
- /* title dsiplay arrary make */
- k=0;
- i=0;
- while ( *textno+k < max_text ){
- logindex=disptext[*textno+k];
- if (intext->text[logindex].text.id==TITLE_ID
- || intext->text[logindex].text.id==NOTITLE_TEXT_ID){
- strncpy(logtitle[i],
- &log[intext->text[logindex].title.pos],
- intext->text[logindex].title.lleng);
- logtitle[i][intext->text[logindex].title.lleng]=0x00;
- if (intext->text[logindex].text.id==TITLE_ID) logkind[i]=1;
- else logkind[i]=0;
- logno[i]=*textno+k;
- i=i+1;
- if (i>=TITLE_LINE_NO) break;
- }
- k=k+1;
- }
- while (i<TITLE_LINE_NO){
- logtitle[i][0]=0x00;
- logno[i]=max_text-1;
- i=i+1;
- }
-
- for (k=0;k<TITLE_LINE_NO;k++){
- if (logkind[k]==0) tcol=TEXT_COL;
- else tcol=NAME_COL;
- linedspv ( 2, k*18+69, logtitle[k],0,tcol,BACK_COL);
- }
-
- n_menu[0].xpos=0;
- n_menu[0].ypos=35;
- n_menu[0].xsize=640;
- n_menu[0].ysize=414;
- n_menu[0].xbtnsize=640;
- n_menu[0].ybtnsize=18;
- n_menu[0].ful=0;
- n_menu[0].disp=0;
- n_menu[0].ini_digit=0;
- while ( (result = panelread (1, n_menu, 1)) >= 2000 );
- if ( result<0 ) action=0;
- else{
- if ( result < 1000 ){
- action=1;
- pos=result;
- }
- else{
- action=2;
- pos=result-1000;
- }
- }
-
- switch ( action ){
- case 0 :
- flag=0;
- MOS_disp( 0 );
- EGB_writePage(egbwork,1);
- box( 0,35,639,459,0,1 );
- EGB_writePage(egbwork,0);
- break;
- case 1 :
- if ( pos==0 ){
- *textno=logno[TITLE_LINE_NO-1]+1;
- if (*textno >= max_text) *textno=logno[0];
- }
- else{
- *textno=logno[pos-1];
- if ( *textno>max_text-1 ) *textno=max_text-1;
- if (intext->text[disptext[*textno]].title.id==TITLE_ID){
- for ( n=*textno;n<max_text-1;n++ ){
- if (intext->text[disptext[n]].text.id
- != TITLE_ID ) break;
- }
- *textno=n;
- }
- flag=0;
- MOS_disp( 0 );
- EGB_writePage(egbwork,1);
- box( 0,35,639,459,0,1 );
- EGB_writePage(egbwork,0);
- }
- break;
- case 2 :
- if ( pos==0 ){
- k=0;
- for (i=logno[0]-1;i>=0;i--){
- workid=intext->text[disptext[i]].text.id;
- if (workid==TITLE_ID || workid==NOTITLE_TEXT_ID) k=k+1;
- if (k>=TITLE_LINE_NO) break;
- }
- if (i<0) *textno=0;
- else *textno=i;
- }
- else{
- flag=0;
- MOS_disp( 0 );
- EGB_writePage(egbwork,1);
- box( 0,35,639,459,0,1 );
- EGB_writePage(egbwork,0);
- break;
- }
- break;
- }
- EGB_color(egbwork, 0, TEXT_COL);
- EGB_clearScreen(egbwork);
- }
- MOS_disp( 0 );
- EGB_color(egbwork, 0, TEXT_COL);
- EGB_color(egbwork, 1, BACK_COL);
-
- return(0);
-
- }
-
-